5. Devices

5.1 MOS 6510 Processor and Emulator Speed

The speed of the Emulator can be controlled using the menu item Options/Emulator Speed.

Reference Clock - PAL vs. NTSC:
PAL and NTSC are two major standards for television signals. While PAL used in most west European contries (except France), NTSC is the common standard in North America. A PAL signal consists of 625 scanlines (including scanlines for vertical blank, leaving a usable resolution of 768x576 pixels) that are displayed at a nominal refresh rate of 50Hz. NTSC on the other hand uses only 525 that are redisplayed at 60Hz. Note that both systems use  interleaving, i.e. during each screen refresh, only every other scanline gets redrawn, thus the entire image is only redrawn at 25Hz(PAL) or 30Hz(NTSC).
When a Commodore 64 is connected to the TV the standards are interpreted in a slightly different manner. The central image of a C64 screen has a resolution of 320x200 pixels. Around this area there is a frame, that stretches the image to about (depending on the actual TV set connected) 384x288(PAL) pixels. To make a full TV signal all pixels are displayed at half the regular TV pixel rate, with the effect, that they are scaled in horizontal direction. Furthermore both half images are then same, resulting in stretched image in vertical direction. Depending on the video mode the internal clock of the C64 is driven at either 0.985MHz (=625*63*50/2 PAL) or 1.023MHz (=525*65*60/2 NTSC). Most C64-programs will work fine in both modes. PAL mode produces less strain on the Mac CPU and is therefore advantageous. Only games that won't work in PAL mode should be run in NTSC mode.

System Clock:
Depending on the choice of video mode the reference clock of the emulated C64 is driven at either 0.985MHz (PAL) or 1.023MHz (NTSC). This frequency is used to drive the CPU and CIAs (Timers) (but not the SID or VIC). You can increase the System Clock rate to obtain a faster C64 while maintaining the speed ratio between CPU and CIA. Note that compatibility will still suffer if you select a value different from 100%.

CPU Clock:
In addition to adjustments to the System Clock it is also possible to accelerate the CPU alone. If you have a CPU intensive program, that you want executed as fast as possible, than this is the parameter to adjust. Note so, that compatibility for games will suffer if you select a value different from 100%.

Frames per Computed Screen & Frames per Screen Redraw:
Power64 maintains the screen in two steps. In a first step it creates an image of the C64 screen in an internal buffer (as a byproduct of this computation Power64 also checks for sprite collisions). This image is compared to the one last computed and only if a change is detected then the changed parts are copied to the Macintosh screen in a second step. Frames per Computed Screen defines how often the first step is performed. Frames per Screen Redraw sets the frequency of the second step. A setting of 1:1 means that the screen is recomputed/redraw 50(PAL) or 60(NTSC) times a second. 1:n indicates that the screen is redone only on every n-th frame. Choosing Auto causes Power64 to select the speed that best fits the C64 game and Macintosh used. Thus Auto is the recommended setting for both Frames per Computed Screen and Frames per Screen Redraw. Only games that require very precise Sprite Collision detection might require Frames per Computed Screen to be set to 1:1. To display the actual number of frames per second enable the menu item Options/Display CPU Load (see below).

Video Emulation:
Power64 currently supports two types of video emulation, that differ in respect to the exact timing of video image calculation. In Scanline mode (which is fastest) the entire scanline is drawn at once at the beginning of the scanline. In contrast to this Advanced Timing mode obtains the Sprite information at the beginning of the scanline, and draws the rest of the image approximately in the middle. These are both approximations of the correct single cycle mode (that will be supported by future versions of Power64) where the image is rendered parallel to the running CPU. Advanced Timing is about slightly slower that Scanline mode, but it can deal correctly with many raster effects that cause flicker in Scanline mode.

Inactive Windows:
When an emulator window is not the active (focused) window, the emulator is usually suspended until its window becomes active again. Stopping the emulation gives other applications the full power of the Mac CPU. On the other hand it is possible to keep the emulation running either with or without sound. This way you can have e.g. a 'Little Computer People' on your desktop, while you work, or can use sound-demos to make your work more pleasurable. Be aware so, that this consumes significant CPU power, so your other applications are slowed down.

Speed Display:
The current performance of the emulator can be displayed in the top right corner of the emulator window. Power64 can display the the speed of the virtual M6510 CPU of the emulated C64 (in MHz) This should be 0.98 of PAL-mode (prefrerred) and 1.02 in NTSC mode. Furthermore Power64 will display how much load is puts on the Mac CPU (in %). For smooth sound and video emulation the Mac-CPU should not be loaded more than 90%. If the second line Power64 displays the number of frames that are displayed and computed per second as well as the number of frames that a real C64 would display.
Use the Speed Display option to indicate which data Power64 should display. If is also possible to turn the display off altogether with Options/Display CPU-Load (Cmd-I). Use Opt-Cmd-I to apply this change to all windows.

After adjusting the preferences use Set Global to make the set of options valid for all emulator windows currently open as well as newly opened. Clicking Ok will only change the options for the current window.

5.2 Video Options

Many aspects of how the C64 image is displayed on the Macintosh screen can be controlled by the user via Options/Video Setup.

Default Window Size:
Power64 can display the screen of an emulated C64 either in single size (1:1 - every C64 pixel corresponds to one Macintosh pixel), double size (1:2 where every C64 pixels is displayed by 2x2 Macintosh pixels) or even tripple/quad size (1:3 / 1:4). All newly opened windows will be displayed in the selected size. To change the display mode of an already open window, click on the zoom box in the top right corner to toggle between single and double size of click Options/Zoom Out (Cmd--) and Options/Zoom In (Cmd-+) to switch up to quadruple size.

Skip Every Other Scanline:
If Skip Every Other Scanline is enabled in Double Screen Size mode Power64 will render each C64 pixel by only 2x1 (rather than 2x2) Macintosh pixels and fills the gap with a black line, effectivly drawing only every other scanline. This does reduce the jagged look of the zoomed image, but unfortunatly also causes a rather dimmed look. Note that skipping every other scanline does NOT significantly increase emulation speed. If you need to free CPU time, switch to single size video!  

Black Frame for Zoomed Window:
When a window size other than 1:1 is selected Power64 can automatically center the emulated C64 on the Macintosh screen and draw a black frame around it to cover any other windows that are on the screen. This is not Macintosh like, but gives more C64 feeling. To hide the menu bar too, see the next point.   

Hide Menubar for Black Frame:
To gain optimal  C64-like feeling it is possible to switch off the menu bar when the emulator is in full screen mode. Thus the screen looks like you would find it on a real C64, nothing reminds of a Macintosh. If this option is selected, the menubar will be hidden after the C64 ran for two seconds in full screen mode. Moving the mouse or pressing the option key brings the menubar back on the screen.

Display Image Frame:
On a real C64 the central screen area is surrounded by a wide frame to adapt the C64's 320x200 pixel screen resolution to the 504*312 (PAL) or 510*262(NTSC) TV resolution. This frame usually is filled with a single color (and thus carries little information). In newer games authors have devised ways to display sprites in the frame (commonly used to display scores and/or scrolling messages). Use Display Image Frame to decide if Power64 should display the frame.

Use Color on Color Screens:
Power64 can display the C64 screen in original colors or as a black and white image. Select Use Color on Color Screens to see original colors on color Macintosh screens. Enabling this option is definitely recommended.

Use Color on Grayscale Screens:
Power64 can display the C64 screen in original colors or as a black and white image. Select Use Color on Color Screens to see the original colors translated to levels of gray on grayscale Macintosh screens. Otherwise Power64 will display the screen in black and white. Beware: Some colors, that are easily distinguishable when seen in color produce nearly the same gray level and might become unreadable if Use Color on Grayscale Screens is enabled. On the other hand a real black/white image can deteriorate into a black in black image that is equally unreadable.

Use Custom Palette:
If Use Custom Palette is selected Power64 will modify the monitors CLUT (Color LookUp Table) to produce the correct colors of a real C64. Otherwise the required colors will be approximated using the standard system colors. This feature is especially useful on a monitor with only 16 colors. The effect is hardly visible on monitors with 256 or more colors.

Accelerated Drawing:
Power64 maintains the screen in two steps. In a first step it creates an image of the C64 screen in an internal buffer. This image is compared to the one last computed and only if a change is detected then the changed parts are copied to the Macintosh screen. This second step can be done using either the original Macintosh Quickdraw routines, that are provide optimal compatibility or special Power64 optimized routines that offer better performance. Unless you are using very exotic video hardware and run into compatibility problems, there should be no reason to turn Accelerated Drawing off.

Flicker Free Window Movement:
Power64 uses special routines for dragging around windows, that produce less flicker when releasing the window. This can cause problems when using system extensions that patch the window dragging routines. For example DragWindow II and ChurchWindows have bugs in their patches that cause Power64's window to jump back to the original position immediately after dragging. Select Flicker Free Window Movement to use the standard Macintosh Toolbox routines for window dragging (even so there is a little flicker when releasing the window) to circumvent this problem.

Switch Screen to Optimal Color Depth:
Power64 has been speed optimized for Macintosh monitors with 256 or 32768 colors. While it will work on screen with millions of colors, there can be severe performance penalties. Power64 can change the monitors color depth for optimal performance. This can either be done automatically, only after confirmation by the user or never.

Restore Colors for other Apps
When Power64 has changed the screens color depth to meet its needs it will automatically restore the original configuration when it is terminated. It can also restore the color depth every time the user switches to a different application. This has the advantage, that other applications can use the normal monitor features. On the other hand this causes a lot of flicker due to screen redraws every time the users switches between Power64 and other applications (like the Finder).

Zoom Out (Cmd -):
Reduce the zoom factor of the current C64 window by one.
Use the Option key to make the new size apply to all open windows.

Zoom In (Cmd-+):
Increase the zoom factor of the current C64 window by one.
Use the Option key to make the new size apply to all open windows.

Black Window:
Power64 is a well-behaved Macintosh application, that runs in regular windows. Outside the Power64 windows the Finder and other applications' windows are visible. To create a more C64-like feeling Power64 has the ability to draw a big black window over the entire screen, that hides all other applications. If you also want to hide the menu bar check "Hide Menubar for Black Frame" above.

5.3 Sound Emulation

Options/Sound Emulation/Mute (Cmd-M) disables the SID emulation. As the SID emulator requires a significant amount of processing time, turning off the sound will give a preformance boost to games that would otherwise be to slow to run at full speed. Even with SID emulation off SID[$1B] can still used as a random number generator.

Options/Sound Emulation/Volume 0(Silent) ... Volume 8(Loud) enables the SID emulation.

Note that while both Volume 0 and Sound Off don't produce any audible sound they are not the same. With Volume 0 the SID is fully emulated and SID[$1B] and SID[$1C] produce correct values, while with Sound Off no emulation takes place and the values in SID[$1B] are produced by a dirty hack.

Pressing the Option key while selecting a new mode for the SID emulation will cause all open Power64 windows to adopt this mode.

5.4 Sound Recording

Power64 also offers the possibility to record the sound played by C64 games to a AIFF  sound file that can be played e.g. with the Simple Player for Quicktime.

To start or stop sound recording press Cmd-*. There is also the prosibiliy to select Options/Sound Emulation/Record Sound as AIFF but it is much harder to select this item at a precise moment. The sounds will be recorded to a file called 'C64 Sound - dd.mm.yyyy (x)'  (where dd.mm.yyyy is the current date and x is a counter) in the Sound File folder (see below).

Using Options/Sound Emulation/Recording Options several features of this export function can be defined:
 
Sample Rate and Sample Size control the sound quality of the recording. A high sampling rate and large sample size give good quality, but unfortunatly also large sound files. Technical Note: Power64 always creates its sound at 22050 Hz, 16 bit, Mono and produces the other sample rates/sizes by discarding part of that information. Therefore there is no speed increase when selecting a lower rate. Furthermore it explains why there is no 44100Hz or Stereo option; The necessary extra data would have to be interpolated, a task that should be done using specialized sound editing software.

Pause Recording during Silence
Power64 can automatically  stop sound recording when there is not tune to record. Enableing this feature causes Power64 to delay any recording until the music starts and eliminate silence after the end of the music. Furthermore any intermission that lasts longer than 1/2 second is truncated to 1/2 second. This is a very useful feature as you can start the recording before running the game without causing useless stretches of silence in the AIFF file. Unfortunatly some games produce sound with lots of intermissions, that sound queer if these intermissions are trucated. For such games it is useful to turn off the Pause Recording feature.

Sound File Folder 
The recorded C64 sounds are stored in a file called 'C64 Sound - dd.mm.yyyy (x)' in the Sound File folder. Click on Select Sound File Folder to choose the folder in which these files are to be stored. Please be aware that a sound file can easily become quite large and make sure that there is enough space on the selected volume. A 22050 Hz 16 bit recording requires 43 KByte/sec or 2.5MByte/min. Also note that recording take place in real time; This requires a sufficiently quick storage device such as a hard disk or ZIP drive. The 3.5" floppy disk drive is NOT fast enough and writing sound files to it might cause incomplete recordings!  

5.5 Keyboard

Power64 supports two keyboard modes - Macintosh Keyboard mode and C64 Keyboard mapping. It is possible to select a Keyboard Mode using the menu items Options/Mac Keyboard and Options/C64 Keyboard. Usually this effects only the active emulator window. If the Option Key is pressed when selecting a new Keyboard mode, than this mode is activated in all emulators.

In Macintosh Keyboard mode the translation between pressed Macintosh keys and logical C64 keys is based on the character that is usually associated with a particular key. ie. Pressing the key (or key combination) that will create a '*' in any Mac word processor will also create a '*' in Power64. This is very handy if you have not used your C64 very much recently and are no longer familiar with its keyboard layout. On the other hand, some keys that require just a single keystroke on a C64 might require the use of Shift/Option+Key on the Macintosh or might not be reachable at all. This might cause problems with programs that require these keys.

As an alternative there exists the C64 Keyboard mode. In this mode the Macintosh Keyboard behaves just like a C64 Keyboard ie. Key mapping is based on the relative (physical) position of the keys on the keyboard. The character that is associated with a key in other Macintosh applications (and that is usually printed on the keycap) is irrelevant in this mode. This offers the advantage that all C64 keys are accessible for the emulator, but it might cause some typos for experienced users on the Macintosh Keyboard.

Macintosh Keyboard mode makes it easy to type (plain) text, as you don't have to think twice (or correct typo's afterwards) whether you are in a Macintosh window or an Power64 window - the keyboard is always the same.

Commodore 64 Keyboard mode is better when you need fine grain emulation. It will enable you to access all the graphic characters available on the Commodore 64. Furthermore those games that use the keyboard to control their hero usually select the action keys in a way that provides convenient access on a Commodore 64 keyboard. On a local keyboard the keys might be shuffled around and impossible to reach. 

Note: If you have a US-keyboard on your Macintosh there is very little difference between the two keyboard modes. You will probably want to use Commodore 64 keyboard mode, as it offers higher compatibility.

The C64 keyboard features some special keys that have been mapped to the Macintosh keyboard by Power64:

    C64              Macintosh
  Run/Stop            Escape
  Restore             Cmd-R (includes Run/Stop)
                            (or Menu: File/Restore)
  Reset               Cmd-K (Press Option-Cmd-K for Hard Reset)
                            (or Menu: File/Reset)
  Commodore           Option
  Control             Control
  Shift (left&right)  Shift
  Shift Lock          Caps Lock

  Insert/Delete       Insert/Help
  Backspace           Backspace or Delete
  Clear/Home          Home

  F1                  F1 or Cmd-1
  F2 (=Shift-F1)      F2 or Cmd-2 or Shift-F1
  F3-F8               Similar to F1/F2

  Cursor Right        Cursor Right
  Shift Cursor Right  Cursor Left or Shift Cursor Right
  Cursor Down         Cursor Down
  Shift Cursor Down   Cursor Up or Shift Cursor Down

    Right Arrow         Underscore('_') (Fire in 'Castle Wolfenstein')

The numeric keypad on a Macintosh keyboard can be used in just like the regular numeric keys in the top row of the keyboard in Power64.

Below are some pictures of the C64 keyboard layout, to help locate all the many graphics characters.
Without any modifier keys the C64 keyboard is very similar to the standard US Macintosh keyboard.

Abrevations:  C/H…Clear/Home - I/D…Insert/Delete 
           RST…Restore - R/S…Run/Stop - LCK…Shift Lock

When SHIFT is pressed (or SHIFT LOCK is active) the following characters can be accessed:

Finally the following characters can be accessed by using the Commodore (Macintosh: Option) modifier key:

 
More text colors are available by pressing CTRL-1..CTRL-8. Use CTRL-9 and CTRL-0 to turn reverse printing on and off.

5.6 Joysticks

Power64 directly supports ADB joysticks, and can also use the Macintosh keyboard to simulate joysticks with optional auto-fire in both game ports of the C64.

To customize the joystick simulation select the menu item Options/Joysticks. Here you can define the keys that are to be used for every direction of joystick movement and the fire button. It is perfectly fine to use the same set of keys for both joysticks. You can define either 4 or 8 directional keys for each joystick.
If you define just 4 keys, than diagonal movements require two keys to be pressed at once. If you want to fire diagonally (making it a total of 3 keys), this can cause problems, as the Mac keyboard has difficulty decoding certain combinations of 3 or more keys. 

There are two ways to using a ADB joystick. First, most joysticks come with software that maps movements on the joystick to pressed keys. Using the approach mentioned above you can map these keys back to C64 joysticks.

Alternately and more Mac-like you can use Input Sprocket the new Apple standard for handling ADB joysticks (available from Apple via FTP at ftp://ftp.apple.com/devworld/Games/). Once you installed Input Sprocket in your system folder, Power64 will automatically recognize your joystick. To do additional configuration (only rarely necessary) choose Configure ADB joysticks.

Furthermore every joystick can be assigned a auto fire rate. Note that even with auto fire activated it is still necessary to press the fire key to activate fire button function in any game. All that auto fire does for you is that is periodically presses and releases the virtual fire button at a given frequency as long as the fire key is pressed.

The C64 uses the same set of I/O Pins of CIA1 to detect both keyboard activity and joystick movement. Due to this hardware design some joystick movements cause the C64 to believe that keyboard activity has taken place. Therefore it is sometimes useful to deactivate a joystick.

Most keys that are accessible on the Macintosh keyboard have an equivalent on the C64 keyboard. Yet it is not desirable that every movement of the virtual joystick (caused by pressing a key on the Mac keyboard) indicates a pressed key to the C64. Therefore it is usually advisable to hide those keys that are used to simulate a joystick from the emulated C64. On the other hand care should be taken not to eliminate any 'important' keys. Usually it is a clever to choose the joystick keys from the numeric keypad, and keep them hidden from the emulated C64.

Some C64 games require a joystick in Port 1 while others will only work with the joystick in Port 2. Use the menu item Options/Swap Joysticks (Cmd-J) to quickly flip a joystick from Port 1 to Port 2 and vice-versa. Pressing the Option-key when selecting this menu item will cause the joysticks to be exchanged in all active emulators.

5.7 Paddles & Light Pen

Power64 can use the mouse to simulate a pair of paddles. Each paddle can be controlled by the horizontal or vertical position of the mouse on the Macintosh screen. By default the paddles are deactivated. Use the menu item Options/Paddles & Light pen define which paddle should be assigned to which direction of the mouse.

Note that the original C64 supports two pairs of paddles, one in each game port. In Power64 the paddles are always connected to both ports. Unless a game was designed to use two pairs of paddles at the same time this should not cause any problems.

Power64 can also use also use the mouse to simulate a lightpen. As there are few C64 applications that support a lightpen this feature is not activated by default. Use Options/Paddles&Light pen to enable the lightpen. Note that it is not possible to select an area of the virtual screen for copying (Edit/Cut or Edit/Copy) while the mouse is used as lightpen.

As both paddles and lightpen are used only in few Commodore 64 programs, these are a rather poorly tested function of Power64. It is very likely that there are still several bugs in both the paddle and (especially) the lightpen code.